/**
 * 
 */
package com.zhaoyan.cms.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.zhaoyan.cms.pojo.Link;

/**
 * @author zhaoyan
 *
 * 2020年2月1日
 */
public interface LinkMapper {

	/**
	 * @return
	 */
	@Select("SELECT id , name ,url ,created FROM cms_link ORDER BY created DESC")
	List<Link> findLinks();

	/**
	 * @param link
	 * @return
	 */
	@Insert("INSERT INTO cms_link VALUES(0,#{url},#{name},now())")
	Integer addLink(Link link);

	/**
	 * @param id
	 * @return
	 */
	@Delete("DELETE FROM cms_link WHERE id = #{value}")
	Integer delLink(Integer id);
	
	
	
	Integer deLinks(List<Integer> ids);

	/**
	 * @param id
	 * @return
	 */
	@Select("SELECT id , name ,url ,created FROM cms_link WHERE id = #{value}")
	Link findLinkById(Integer id);

	/**
	 * @param link
	 * @return
	 */
	@Update("UPDATE cms_link SET `name` = #{name} , `url` = #{url} WHERE  `id` = #{id}")
	Integer updateLink(Link link);

	/**
	 * @return
	 */
	@Select("SELECT id , name ,url ,created FROM cms_link ORDER BY created DESC")
	List<Link> findLinkList();
	
	
	

}
